<?php
$page_title = "优秀模式收集";
$style = "css/main.css";
$page_id = "page_collection";
require "./include/header.php";
require "getcollection.php";
require "class_xml.php";
?>
<div class="mainwrap"><div class="mainwrap-inner">

	<?php
	$xml = file_get_contents($rootdir."collection/data.xml");//读取XML文件
	$data = XML_unserialize($xml);
	$i = 1;
	$cid = ($_GET["cid"]) ? $_GET["cid"] : "";
	$pid = ($_GET["pid"]) ? $_GET["pid"] : "";
	$id = ($_GET["id"]) ? $_GET["id"] : "";
	$parseid = explode("-",$id);
	$picurl = $baseurl."collection/";
	$pcc = $percolumn_collection;
	$pc = (710 - ($pcc-1) * 10) / $pcc;
	if ((!$cid)&&(!$pid)&&(!$id)) {
		showModuleWrapBegin("module module_simple notop","","","","");
		echo "Web Pattern旨在建立一套通用的HTML/CSS代码片段，供平时的使用来套用，主要分为四个部分";
		showModuleWrapEnd();
		foreach ($data["Collection"]["category"] as $data_category) {
			if($i%$pcc==0) {
				showModuleWrapBegin("module module_s3 notop",$pc."px","","left","");
			} else {
				showModuleWrapBegin("module module_s3 notop",$pc."px","","left","10px");
			}
			echo "<h3><a href=\"?cid=".$data_category["id"]."\">".$data_category["title"]."</a></h3>\n";
			echo "<ul class=\"list-items\">\n";
			$j = 0;
			foreach (array_reverse($data_category["item"]) as $data_item) {
				if ($j < $limit_collection_module) {
					echo "<li><a href=\"?cid=".$data_category["id"]."&pid=".$data_item["id"]."\" title=\"".$data_item["title"]."\">".utf8_trim($data_item["title"],40)."</a></li>\n";
				}
				$j++;
			}
			echo "</ul>\n";
			showModuleWrapEnd();
			$i++;
		}
	} elseif (($cid)&&(!$pid)&&(!$id)) {
		foreach ($data["Collection"]["category"] as $data_category) {
			if ($data_category["id"] == $cid) {
				showModuleWrapBegin("module module_s1 notop module-pattern-list","","","","");
				echo "<div class=\"path\"><a href=\"".$baseurl."collection.php\">优秀模式</a> &gt; ".$data_category["title"]."</div>\n";
				echo "<h3>".$data_category["title"]."</h3>\n";
				echo "<p class=\"desc\">".$data_category["desc"]."</p>\n";
				echo "<ul class=\"list-items\">\n";
				foreach (array_reverse($data_category["item"]) as $data_item) {
					echo "<li><a href=\"?cid=".$data_category["id"]."&pid=".$data_item["id"]."\" title=\"".$data_item["title"]."\"><img src=\"".$picurl.$data_category["part"]."/".$data_item["id"]."-m.png\" alt=\"".$data_item["title"]."\"/></a></li>\n";
				}
				echo "</ul>\n";
				showModuleWrapEnd();
			}
		}
	} elseif (($cid&&$pid&&!$id)||(($cid&&!$pid&&$parseid[1])&&($cid==$parseid[0]))||((!$cid&&$pid&&$parseid[1])&&($pid==$parseid[1]))||(($cid&&$pid&&$parseid[1])&&($cid==$parseid[0]&&$pid==$parseid[1]))||(!$cid&&!$pid&&$parseid[1])) {
		if ($parseid[1]) { $cid = $parseid[0]; $pid = $parseid[1]; }
		foreach ($data["Collection"]["category"] as $data_category) {
			if ($data_category["id"] == $cid) {
				foreach ($data_category["item"] as $data_item) {
					if ($data_item["id"] == $pid) {
						showModuleWrapBegin("module module_s1 notop module-pattern-item","","","","");
						echo "<div class=\"path\"><a href=\"".$baseurl."collection.php\">优秀模式</a> &gt; <a href=\"".$baseurl."collection.php?cid=".$cid."\">".$data_category["title"]."</a></div>\n";
						echo "<h3>".$data_item["title"]."</h3>\n";
						echo "<div class=\"url\">参考：<a href=\"".$data_item["url"]."\" rel=\"external\">".$data_item["url"]."</a></div>\n";
						echo "<a class=\"lightbox\"  href=\"".$picurl.$data_category["part"]."/".$data_item["id"]."-l.png\" rel=\"roadtrip\" title=\"".utf8_trim($data_item["desc"],50)."\"><img src=\"".$picurl.$data_category["part"]."/".$data_item["id"]."-m.png\" alt=\"".$data_item["title"]."\"/></a>\n";
						echo "<p class=\"desc\">".$data_item["desc"]."</p>\n";
						if (!empty($data_item["code"])) {
							echo "<p>实现代码如下:</p><blockquote>" .$data_item["code"]. "</blockquote>\n";
						}
						/*
						echo "ID：" . $data_item["id"] . "<br/>";
						echo "名称：" . $data_item["title"] . "<br/>";
						echo "简介：" . $data_item["desc"] . "<br/>";
						echo "地址：" . $data_item["url"] . "<br/>";
						echo "代码：" . $data_item["code"] . "<br/>";
						*/
						showModuleWrapEnd();
					}
				}
			}
		}
	} else {
		showModuleWrapBegin("module module_s1 notop","","","","");
		echo "参数有误";
		showModuleWrapEnd();
	}

/*
	echo "<pre>";
	print_r($data);
	echo "</pre>";
*/
	?>

</div></div>
<div class="sidewrap"><div class="sidewrap-inner">
<?php
require "sidebar.php";
?>
</div></div>


<?php
require "footer.php";
?>

